import * as DB from "@/compoment/DB.js"
export function getRandomChineseWord () {
	let arr = ["1","朵","谷","寄","彭","邀","亚","旦","鸿","雷","剑","三","界","魔","神","鬼","事","死","王","六","九","2","3","呆子"]
	let arr2 = ["仙","谪","牛","回","街","心","五","七","八","泪","青","清","之","皮","赌","异","垒","重","木","吃","佛","山","地","梅"]
	let arr3 = ["师姐","世界","魔王","魔","神仙","神奇","第一","威力","好","我是","洪荒","鸿蒙","天地","无","大","生肖","守","破","重","重","异世"]
	let arr4 = ["天雷","亡","重生","穿越","创","盘","转世","七万","女娲","女王","伏羲","秦朝","雷利","古","股市","古神","美女","盘龙","盘","龙","命"]
	let arr5 = ["武侠","无","网游","人","高手","高","一","魂","魂魄","落魄","想","明","骑","神","霆","主人","主","奴","域","鱼人","东","玲"]
	let arr6 = ["玄","轩","游","人间","术","才","南","历史","鸿钧","祖","老子","通","始","鸣","开天","弟","音乐","录","兵","王","塔","兵"]
	let data = arr.concat(arr2,arr3,arr4,arr5,arr6);
	var _rsl = data[Math.floor(Math.random() * data.length)];
	return _rsl;
}

// 查询数据库中所有收藏的书籍
export async  function findDBShelfBook(){
	let data = null;
	data =  await DB.find(DB.config.tables.uu_bookShelf).then((res)=>{
		return  res
	}).catch((err)=>{
		return  null;
	})
	return data
}

//查询某本书籍本机数据库的所有章节
export async function findBookChapter(book){
	let data = null;
	data =  await DB.find(DB.config.tables.uu_bookChapter,{'fictionId':book.fictionId}).then((res)=>{
		return res
	}).catch(()=>{
		return null;
	})
	return data
}
// 删除书籍的所有章节
export async  function removeBookChapters(book){
	await DB.remove(DB.config.tables.uu_bookChapter,{"fictionId":book.fictionId}).then(()=>{
		console.log("删除成功")
	}).catch(()=>{
		console.log("删除失败")
	})
}
/**
 * 获取某本书是否需要更新章节，返回false不更新，true更新
 */
/* export function bookIsUpdateChapter(httpBookChapterListCount, fiction){
	let count = DB.findCount(DB.config.tables.uu_bookChapter,fiction)
	return httpBookChapterListCount == count?false:true;
} */

